import 'package:trade/common/network/single_protocol.dart';
import 'package:trade/common/util/ai_json/ai_json.dart';
import 'package:trade/data/bean/market_data_bean.dart';

/// Author: Karl
/// Date: 2021/6/8 下午3:29
/// Description: KLine APi

class KLineSymbolsApi extends SingleProtocol<KLineSymbolsApi> {
  List<String> tradePairs = [];

  @override
  String get api => "/kline/symbols";

  @override
  void onParse(data) {}

  WDRequestType get method => WDRequestType.get;
}

class KLineListApi extends SingleProtocol<KLineListApi> {
  final String symbol;
  final String period;
  final String size;

  KLineListApi(this.symbol, this.period, this.size);

  @override
  String get api => "/kline/marketData";

  MarketDataBean tickerBean = MarketDataBean();
  List? klineData;
  @override
  void onParse(data) {
    AiJson aiJson = AiJson(data);
    tickerBean = MarketDataBean.fromJson(aiJson.getMap("ticker"));
    klineData = aiJson.getArray('list');
  }

  @override
  Map<String, dynamic>? get arguments => {
        "symbol": symbol,
        "period": period,
        "size": size,
      };

  WDRequestType get method => WDRequestType.get;
}
